package com.alan.shiro.controller;

import com.alan.shiro.bean.ResultMap;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: Alan liu
 * @Date: 2018/12/11 19:13
 * @Description: 普通登陆用户
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @RequestMapping(value = "/getMessage", method = RequestMethod.GET)
    public ResultMap getMessage() {
        return new ResultMap().success().message("您拥有用户权限，可以获得该接口的信息！");
    }

    /**
     * 注解的使用
     * @return
     */
    @RequiresRoles("user")
    @RequiresPermissions("create")
    @RequestMapping(value = "/create", method = RequestMethod.GET)
    public ResultMap create() {
        return new ResultMap().success().message("您拥有用户create权限，可以获得该接口的信息！");
    }

    @RequiresRoles("user")
    @RequiresPermissions("select")
    @RequestMapping(value = "/select", method = RequestMethod.GET)
    public ResultMap select() {
        return new ResultMap().success().message("您拥有用户select权限，可以获得该接口的信息！");
    }


}
